

#import "LLUserManager.h"
#import "LLLoginViewController.h"

#define LLPublishModelFilePath    ([[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSString stringWithFormat:@"PublishModel"]])
#define PositioningModelFilePath    ([[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSString stringWithFormat:@"PositioningModel.file"]])
#define LoginModelFilePath    ([[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSString stringWithFormat:@"LoginModelFilePath"]])

@implementation LLUserManager

/// 登录
+ (void)login {
    [LLUserDefaults setObject:@"1" forKey:LLLoginStatus];
    [LLUserDefaults synchronize];
}

/// 退出登录
+ (void)logout {
    [LLUserInfo clearLocalUserInfo];
    [LLUserDefaults setObject:@"0" forKey:LLLoginStatus];
    [LLUserDefaults synchronize];
}

/// 是否是登录状态,如果不是，弹出登录控制器
+ (BOOL)isLogin {
    BOOL isLogin = [[LLUserDefaults objectForKey:LLLoginStatus] integerValue] == 1;
    if (!isLogin) {
        LLNavViewController *nav = [[LLNavViewController alloc] initWithRootViewController:LLLoginViewController.new];
        [[UIViewController currentViewController] presentViewController:nav animated:YES completion:nil];
    }
    return isLogin;
}

/// 是否是登录状态,如果不是，不弹出登录控制器
+ (BOOL)isLoginNoPresent {
    BOOL isLogin = [[LLUserDefaults objectForKey:LLLoginStatus] integerValue] == 1;
    return isLogin;
}



@end




